Let's extract the max element from our heap.
- 1. Save max value: 101 is saved, and the last element, 17, is removed from the end of the array.
- 2. Move last to root: The element 17 is placed at the root to maintain the complete tree shape.
- 3. Bubble Down:
- Compare 17 with children 36 and 100. Swap with the largest child, 100.
- Compare 17 with its new children 25 and 1. Swap with the largest child, 25.
- 4. Done: 17 is now a leaf, so the heap property is restored. Return 101.
Array Representation